<template>
<van-tabs sticky>
  <van-tab title="夜不归宿">
    <van-form :data="addList">
      <van-field
        v-model="addList.studentName"
        name="姓名"
        label="姓名"
        placeholder="姓名"/>
        <van-field
        v-model="addList.studentId"
        name="学号"
        label="学号"
        placeholder="学号"/>
        <van-field
        v-model="addList.buildNo"
        name="楼号"
        label="楼号"
        placeholder="楼号"/>
        <van-field
        v-model="addList.dormNo"
        name="寝室号"
        label="寝室号"
        placeholder="寝室号"/>
        <van-field
        v-model="addList.bedNo"
        name="床位"
        label="床位"
        placeholder="床位"/>
        <van-field
        v-model="addList.professional"
        name="学院班级"
        label="学院班级"
        placeholder="学院班级"/>
        <van-field
        v-model="addList.counselor"
        name="辅导员"
        label="辅导员"
        placeholder="辅导员"/>
        <van-field
        v-model="addList.commitMan"
        name="提交者"
        label="提交者"
        placeholder="提交者"/>
        <van-field
        v-model="addList.remarks"
        name="备注"
        label="备注"
        placeholder="备注"/>
      </van-form>
      <div style="margin: 16px;">
        <van-button round block type="info" @click="commitAddNight">提交</van-button>
      </div>
      </van-tab>
      <!-- 安全 -->
      <van-tab title="安全">
    <van-form :data="addList">
      <van-field
        v-model="addList.studentName"
        name="姓名"
        label="姓名"
        placeholder="姓名"/>
        <van-field
        v-model="addList.studentId"
        name="学号"
        label="学号"
        placeholder="学号"/>
        <van-field
        v-model="addList.buildNo"
        name="楼号"
        label="楼号"
        placeholder="楼号"/>
        <van-field
        v-model="addList.dormNo"
        name="寝室号"
        label="寝室号"
        placeholder="寝室号"/>
        <van-field
        v-model="addList.bedNo"
        name="床位"
        label="床位"
        placeholder="床位"/>
        <van-field
        v-model="addList.professional"
        name="学院班级"
        label="学院班级"
        placeholder="学院班级"/>
        <van-field
        v-model="addList.counselor"
        name="辅导员"
        label="辅导员"
        placeholder="辅导员"/>
        <van-field
        v-model="addList.counselor"
        name="辅导员"
        label="辅导员"
        placeholder="辅导员"/>
        <van-field
        v-model="addList.vioThing"
        name="违纪物品"
        label="违纪物品"
        placeholder="违纪物品"/>
        <van-field
        v-model="addList.vioNum"
        name="违纪数量"
        label="违纪数量"
        placeholder="违纪数量"/>
        <van-field
        v-model="addList.remarks"
        name="备注"
        label="备注"
        placeholder="备注"/>
      </van-form>
      <div style="margin: 16px;">
        <van-button round block type="info" @click="commitAddSave">提交</van-button>
      </div>
      </van-tab>
      <!-- 卫生 -->
      <van-tab title="安全">
    <van-form :data="addList">
      <van-field
        v-model="addList.studentName"
        name="姓名"
        label="姓名"
        placeholder="姓名"/>
        <van-field
        v-model="addList.studentId"
        name="学号"
        label="学号"
        placeholder="学号"/>
        <van-field
        v-model="addList.buildNo"
        name="楼号"
        label="楼号"
        placeholder="楼号"/>
        <van-field
        v-model="addList.dormNo"
        name="寝室号"
        label="寝室号"
        placeholder="寝室号"/>
        <van-field
        v-model="addList.bedNo"
        name="床位"
        label="床位"
        placeholder="床位"/>
        <van-field
        v-model="addList.professional"
        name="学院班级"
        label="学院班级"
        placeholder="学院班级"/>
        <van-field
        v-model="addList.counselor"
        name="辅导员"
        label="辅导员"
        placeholder="辅导员"/>
        <van-field
        v-model="addList.counselor"
        name="辅导员"
        label="辅导员"
        placeholder="辅导员"/>
        <van-field
        v-model="addList.score"
        name="分数"
        label="分数"
        placeholder="分数"/>
        <van-field
        v-model="addList.remarks"
        name="备注"
        label="备注"
        placeholder="备注"/>
      </van-form>
      <div style="margin: 16px;">
        <van-button round block type="info" @click="commitAddSave">提交</van-button>
      </div>
      </van-tab>
  </van-tabs>
</van-form>

</template>

<script>
import request from "@/utils/request";
import {getUserName} from "@/utils/auth";

export default {
  data() {
    return {
      addList:{
        date:'',
        studentName:'',
        studentId:'',
        buildNo:'',
        dormNo:'',
        bedNo:'',
        professional:'',
        counselor:'',
        vioType:'',
        vioThing:'',
        score:'',
        vioNum:'',
        commitMan:'',
        remarks:''
      },
    };
  },
 mounted(){
   this.getCommitName()
 },
  methods: {
getCommitName(){
  this.addList.commitMan = getUserName()
  },
    commitAddNight(){
      this.addList.vioType = '1'
      this.commitAdd()
    },
    commitAddSave(){
      this.addList[0].vioType = '2'
      this.commitAdd()
    },
    commitAdd() {
      this.addLineShowNight=false
      console.log(this.addList);
      var addList = this.addList
      request({
        url: "/api/violation/addVio",
        method: "post",
        data: addList
      }).then(res => {
        if (res.status === 1) { 
        }
      });
    }
  }
};
</script>